package com.xuhai.blog.admin.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.xuhai.blog.admin.entity.ArticleCategoryEntity;
import com.xuhai.blog.admin.entity.ArticleEntity;
import com.xuhai.blog.admin.mapper.ArticleCategoryMapper;
import com.xuhai.blog.admin.service.ArticleCategoryService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author 机蜂
 * @since 2022-02-08
 */
@Service
public class ArticleCategoryServiceImpl extends ServiceImpl<ArticleCategoryMapper, ArticleCategoryEntity> implements ArticleCategoryService {

    @Autowired
    private ArticleCategoryMapper articleCategoryMapper;

    @Override
    public List<ArticleEntity> getArticleByCategoryId(Integer categoryId) {
        return articleCategoryMapper.getArticleByCategoryId(categoryId);
    }

    @Override
    public void deleteByArticleId(Integer articleId) {
        this.remove(new QueryWrapper<ArticleCategoryEntity>().eq("article_id",articleId));
    }
}
